# 2024/12/28
# file name: data_clean.py

def data_clean(input_file):
    import pandas as pd
    # input_file = '../data/GoodsOrder.csv'
    data = pd.read_csv(input_file)

    data['Goods'] = data['Goods'].apply(lambda x: ',' + x)
    data = data.groupby(['id']).sum().reset_index()

    data['Goods'] = data['Goods'].apply(lambda x: [x[1:]])
    data_list = list(data['Goods'])
    data_translation = []
    for i in data_list:
        p = i[0].split(',')
        data_translation.append(p)

    # print(f"数据转换前5个元素：\n{data_translation[0:5]}")
    return data_translation


if __name__ == '__main__':
    print(data_clean('../data/GoodsOrder.csv'))
